package com.uniflow.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 组织架构实体类
 * 
 * @author uniflow
 * @since 1.0.0
 */
@TableName("organizations")
public class Organization {
    
    /**
     * 组织ID
     */
    private String id;
    
    /**
     * 组织名称
     */
    private String name;
    
    /**
     * 组织描述
     */
    private String description;
    
    /**
     * 父级组织ID
     */
    private String parentId;
    
    /**
     * 负责人ID
     */
    private String managerId;
    
    /**
     * 排序顺序
     */
    private Integer sortOrder;
    
    /**
     * 外部系统部门ID
     */
    private String externalId;
    
    /**
     * 数据来源
     */
    private String syncSource;
    
    /**
     * 最后同步时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime lastSyncAt;
    
    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createdAt;
    
    /**
     * 更新时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updatedAt;
    
    /**
     * 父级组织（关联查询时使用）
     */
    private Organization parent;
    
    /**
     * 子级组织列表（关联查询时使用）
     */
    private List<Organization> children;
    
    /**
     * 负责人信息（关联查询时使用）
     */
    private User manager;
    
    /**
     * 组织下的用户列表（关联查询时使用）
     */
    private List<User> users;
    
    // 构造函数
    public Organization() {}
    
    public Organization(String id, String name) {
        this.id = id;
        this.name = name;
    }
    
    // Getter和Setter方法
    public String getId() {
        return id;
    }
    
    public void setId(String id) {
        this.id = id;
    }
    
    public String getName() {
        return name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
    public String getDescription() {
        return description;
    }
    
    public void setDescription(String description) {
        this.description = description;
    }
    
    public String getParentId() {
        return parentId;
    }
    
    public void setParentId(String parentId) {
        this.parentId = parentId;
    }
    
    public String getManagerId() {
        return managerId;
    }
    
    public void setManagerId(String managerId) {
        this.managerId = managerId;
    }
    
    public Integer getSortOrder() {
        return sortOrder;
    }
    
    public void setSortOrder(Integer sortOrder) {
        this.sortOrder = sortOrder;
    }
    
    /**
     * 设置排序号（别名方法）
     */
    public void setOrderNum(Integer orderNum) {
        this.sortOrder = orderNum;
    }
    
    /**
     * 获取排序号（别名方法）
     */
    public Integer getOrderNum() {
        return this.sortOrder;
    }
    
    public String getExternalId() {
        return externalId;
    }
    
    public void setExternalId(String externalId) {
        this.externalId = externalId;
    }
    
    public String getSyncSource() {
        return syncSource;
    }
    
    public void setSyncSource(String syncSource) {
        this.syncSource = syncSource;
    }
    
    public LocalDateTime getLastSyncAt() {
        return lastSyncAt;
    }
    
    public void setLastSyncAt(LocalDateTime lastSyncAt) {
        this.lastSyncAt = lastSyncAt;
    }
    
    public LocalDateTime getCreatedAt() {
        return createdAt;
    }
    
    public void setCreatedAt(LocalDateTime createdAt) {
        this.createdAt = createdAt;
    }
    
    public LocalDateTime getUpdatedAt() {
        return updatedAt;
    }
    
    public void setUpdatedAt(LocalDateTime updatedAt) {
        this.updatedAt = updatedAt;
    }
    
    public Organization getParent() {
        return parent;
    }
    
    public void setParent(Organization parent) {
        this.parent = parent;
    }
    
    public List<Organization> getChildren() {
        return children;
    }
    
    public void setChildren(List<Organization> children) {
        this.children = children;
    }
    
    public User getManager() {
        return manager;
    }
    
    public void setManager(User manager) {
        this.manager = manager;
    }
    
    public List<User> getUsers() {
        return users;
    }
    
    public void setUsers(List<User> users) {
        this.users = users;
    }
    
    @Override
    public String toString() {
        return "Organization{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", parentId='" + parentId + '\'' +
                ", managerId='" + managerId + '\'' +
                ", sortOrder=" + sortOrder +
                ", createdAt=" + createdAt +
                '}';
    }
}